# Contributor: Daniel Isaksen <d@duniel.no>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=yara
pkgver=4.5.0
pkgrel=0
pkgdesc="The pattern matching swiss knife for malware researchers"
url="https://virustotal.github.io/yara/"
arch="all"
license="BSD-3-Clause"
makedepends="
	autoconf
	automake
	file-dev
	flex
	libtool
	linux-headers
	openssl-dev
	"
subpackages="$pkgname-dev $pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/VirusTotal/yara/archive/v$pkgver.tar.gz
	frozen-tests.patch
	lfs64.patch
	"

# secfixes:
#   4.2.0-r0:
#     - CVE-2021-45429

prepare() {
	default_prepare
	autoreconf -fiv
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--with-crypto \
		--enable-magic
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm644 COPYING -t "$pkgdir"/usr/share/licenses/$pkgname/
	install -Dm644 README.md -t "$pkgdir"/usr/share/doc/$pkgname/
	cp -r docs "$pkgdir"/usr/share/doc/$pkgname/
}

sha512sums="
c9fe8a89879d1a742236101f1754e6b25e70356cdf5c020b2583e3ac509600c3b462756c412b01f2ebcb17df351c83afcf04d1cfaa87e6753eb25bab0f797aa3  yara-4.5.0.tar.gz
7409cc9b10e45d49ef5def47ece19db34e18c7dada007cb8d27879b07374e57913ce4489df9d4bd6bd86706505fb29ee847362dcd3863eeaa6397277012f418f  frozen-tests.patch
6aafb018b6744118d4a448bf7dca679fa0ff7fc63943a6441501c4d8d753769c839f6bbe5c13b4db7283175cd229c0adfa9cdeec64ab27bb4ef3932824edbf08  lfs64.patch
"
